<extend name="layout/application"/>
<block name="content">
    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">广告列表</strong> /
                <small>Ads List</small>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-12">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <a type="button" class="am-btn am-btn-default" href="{{:Url('Adverts/create')}}">
                            <span class="am-icon-plus"></span> 新增
                        </a>
                        <a class="am-btn am-btn-default am-btn-xs delete_all am-text-danger am-hide-sm-only"
                           href="javascript:;">
                            <span class="am-icon-trash-o"></span> 删除
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <div class="am-g" style="margin-left: 45%">
            <div class="am-u-sm-12 am-u-md-12">
                <form class="am-form-inline" role="form" method="get">

                    <div class="am-form-group">
                        <input type="text" name="name" class="am-form-field am-input-sm" placeholder="广告名">
                    </div>
                    <div class="am-form-group">
                        <select data-am-selected="{btnSize: 'sm', maxHeight: 360, searchBox: 1}"
                                name="advertisement_node_id">
                            <option value="-1">所有分类</option>
                            <foreach $cates as $cate>
                                <option value="{{$cate.id}}">{{$cate.name}}</option>
                            </foreach>
                        </select>
                    </div>
                    <button type="submit" class="am-btn am-btn-default am-btn-sm">查询</button>
                    <a href="{{:Url('Adverts/index')}}" class="am-btn am-btn-default am-btn-sm"
                       type="button">重置</a>
                </form>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form">
                    <table class="am-table  am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-check"><input type="checkbox" class="checked_all"/></th>

                            <th class="table-id">编号</th>
                            <th class="table-thumb">略缩图</th>
                            <th class="table-name">标题</th>
                            <th style="width: 20%;">所属栏目</th>
                            <th class="table-is-show am-hide-sm-only">描述</th>
                            <th class="table-sort-order am-hide-sm-only" style="width:10%">排序</th>
                            <th>发布时间</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <foreach $adverts as $advert>
                            <tr data-id="" class="xParent">
                                <td><input type="checkbox" name="checked_id[]" class="checked_id" value="">
                                <td>{{$advert.id}}</td>
                                <td>
                                    <img src="{{$advert.photo.image}}" style="width:80px;height:60px;">
                                </td>
                                <td>{{$advert.name|mb_substr=0,10}}</td>
                                <td>{{$advert.cate.name}}</td>
                                <td>{{$advert.desc|mb_substr=0,10}}</td>
                                <td class="am-hide-sm-only">{{$advert.sort}}</td>
                                <td>{{$advert.created_at}}</td>
                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                               href="/admin/adverts/edit?id={{$advert['id']}}">
                                                <span class="am-icon-pencil-square-o"></span> 编辑
                                            </a>

                                            <a class="am-btn am-btn-default am-btn-xs delete_category am-text-danger am-hide-sm-only"
                                               href="/admin/adverts/delete?id={{$advert['id']}}">
                                                <span class="am-icon-trash-o"></span> 删除
                                            </a>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                </form>
                <div class="am-cf">
                    共{{:count($adverts)}}条记录
                    <div class="am-fr">
                        <ul class="am-pagination">
                            {{$adverts|raw}}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>